package com.hkbigdata.datagovernance.task;

import com.hkbigdata.datagovernance.governance.service.GovernanceAssessDetailService;
import com.hkbigdata.datagovernance.meta.service.TableMetaInfoService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AssessScheduleTask {
    @Autowired
    TableMetaInfoService tableMetaInfoService;
    @Autowired
    GovernanceAssessDetailService governanceAssessDetailService;

    @Value("${assess.schemas}")
    String schemaName;

//    @Scheduled(cron = "* 0/10 * * * *")
    public void assess() {
//        考评日期
        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");

//        获取库名，使用','分割获取
        for (String s : schemaName.split(",")) {
            //        元数据调度
            tableMetaInfoService.initMetaInfo(assessDate, s);
        }

//        考评
        governanceAssessDetailService.mainAssess(assessDate);

    }

}
